
<%@ page language="java" import="java.util.*" %>
 
<jsp:directive.page import="Connectivity.Logger"/>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
<jsp:directive.page import="java.sql.Connection"/>
<%-- <jsp:directive.page import="org.apache.commons.collections.OrderedMap"/>
 --%><jsp:directive.page import="java.sql.CallableStatement"/>
<jsp:directive.page import="java.sql.ResultSet"/>
<jsp:directive.page import="java.sql.Types"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String printFlag="false";
int from=0;
String dbConnVar="";
try {

 

	if(request.getParameter("printFlag") != null){
			printFlag = request.getParameter("printFlag");
		}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 	
    <base href="<%=basePath%>"> 
    
    <title>Call Status</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    
    <script language="javaScript">
     function callsubmit(){
			document.call_status.action = "<%=basePath%>form/general/CallStatus.jsp";
			document.call_status.submit();
	 }
	 function printClick(){
		document.call_status.action = "<%=request.getContextPath()%>/form/general/CallStatus.jsp?printFlag=true";
		document.call_status.submit();
	 }
	
	 function move(frm) 
	 {
		var printFlag = document.call_status.printFlag.value
		document.call_status.from.value = frm;
		document.call_status.action = "<%=request.getContextPath()%>/form/general/CallStatus.jsp?from=" + frm + "&printFlag="+printFlag;
		document.call_status.submit();
	 } // end of function move()
    </script>
    </head>
    
<%
 	if(printFlag.trim().equalsIgnoreCase("false")){
 %>   
  <body   leftmargin="0" topmargin="0">
<%--   <jsp:include page="/other/Header.jsp" />
 --%><%
	}else{
%>	
	<body leftmargin="0" topmargin="0">
	 <%-- <jsp:include page="/MasterHeader.jsp">
 	  --%><jsp:param name="close_flag" value="false"/> 
	 </jsp:include>
<%
	}
%>
   
	<form name="call_status" method="get" >
		<table class="maintable" align="center" >
			<input type="hidden" name="printFlag" value=<%=printFlag%>>
			<input type="hidden" name="from" value = "<%=from%>">
			
			<tr>
				<td  align="center" colspan="15"><b>CALL STATUS REPORT</b></td>	
			</tr>
				
<%     
 
		Connection con1=ConnectionManager.getConnection();
		String call_type= null;
		String enroll=null, temp=null, rollno=null, studname=null, address=null,citystatepin=null, total_address=null;
	 
		if(request.getParameter("call_type")!= null){
			call_type = request.getParameter("call_type");
		}
		if(request.getParameter("from") == null ) {
			from = 0; 
		} else {
			from = Integer.parseInt(request.getParameter("from"));
		}
		
		int eachPageRecords = 25;
		int pageLinks = 0;
		int totRecords = 0;
		int counter = 0;
	
		if(request.getParameter("recordCount")!=null && !request.getParameter("recordCount").trim().equals("")){
			eachPageRecords = Integer.parseInt(request.getParameter("recordCount"));
		}
		if(printFlag.trim().equalsIgnoreCase("false")){		
  		 	
  				
%>    
    	<tr>
			<td  align="left" colspan="2"><b>TYPE </b></td>
   			<td  align="left" colspan="3">
    				<select name="call_type" onchange="callsubmit();"  >
    					<option value=0>--Select--</option>
    					<option value=OPEN>OPEN</option>
    					<option value=CLOSED>CLOSED</option>
    					<option value=ASSIGNED>ASSIGNED</option>
    					<option value=PFP>PENDING FOR PARTS</option>
    					<option value=MTAKEN>MATERIAL TO GIVE</option>
						</select>
					</td>
		</tr>
		<tr>
			<td  align="left" colspan="2"></td>
		</tr>
		
		
		<% }//end of if(printFlag.trim().equalsIgnoreCase("false"))
		
			boolean isShow = false;
		if(call_type != null)
		{
		  Connection databasecon=ConnectionManager.getConnection();
		 	CallableStatement cstmt = null;
		ResultSet calldisplayrs = null;
 
			cstmt = databasecon.prepareCall("{?=call fun_retrieve_callentry(?,?)}");
			cstmt.registerOutParameter(1, Types.OTHER);
			cstmt.setString(2, "OPEN");
			cstmt.setObject(3, calldisplayrs);
			
			databasecon.setAutoCommit(false);
			cstmt.execute();
			
			calldisplayrs =(ResultSet) cstmt.getObject(1);	
 	
 	  int result = 0;
 	  while(calldisplayrs.next()){result++;}
 	
			out.println("result:"+result);
			out.println("result:"+call_type);
			//OrderedMap omlist=null;// = cmBean.getClasswiseStudentList(classStructureId);
			int noOfRecords = 0; 
			if(result>0){
				noOfRecords=result;
				pageLinks = noOfRecords / eachPageRecords;
				if(noOfRecords % eachPageRecords != 0){
					pageLinks++;
				}
				//Iterator omIter = omlist.orderedMapIterator();
				
			
		%>	
			<tr>
				<td  align="center" width='10%'><b>Sr. No.</b></td>
				<td  align="center" width='15%'><b>Roll No.</b></td>
				<td  align="center" width='15%'><b>Enrollment No.</b></td>			
				<td  align="center" nowrap width='30%'><b> Student Name</b></td>
				<td  align="center" width='30%'><b>Address</b></td>
			
			</tr>
			<%
			int cnt = 0 ;	
			String area ="", city="",state="", pincode="";
			 
			while(calldisplayrs.next()) {
				if(cnt == from){
					isShow = true;
				}	
				 isShow = true;
				if(isShow)
				{
					 
				%>
				<tr>
					<td class="MTTD2" align="center"><%=cnt+1%></td>
					<td class="MTTD2" align="center"><%=calldisplayrs.getString(1)%></td>
					<td class="MTTD2" align="center"><%=calldisplayrs.getString(2)%></td>				
					<td class="MTTD2" align="left"><%=calldisplayrs.getString(3)%></td>
					<td class="MTTD2" align="left"><%=calldisplayrs.getString(4)%></td>
				</tr>
				<input type="hidden" name="recordCount" value="<%=eachPageRecords%>">
				<input type="hidden" name="call_type" value="<%=call_type%>">
		<%
			}// END OF if(isShow)
	 		if((cnt - from) == (eachPageRecords-1)){
	 			isShow = false;
	 		}
			cnt++;	
			}//end of while
			
			if(printFlag.trim().equalsIgnoreCase("false") && result>0){
%>
							
				<tr>
					<td colspan="7" align="right">
						<a href="javascript:printClick();"><font color ="blue"><u>Printable View</u></font></a>
					</td>
				</tr>	
<%
			}
%>	
</table>
<br>
<div id='hideFooter'>
<%
int tempResult = 0;
String hrefMove = " ";
if(pageLinks>1){%>
<table  style="width:95%" align="center">
<tr>
	<td  align="center" colspan="15" >
		<%
	  	
	  	
		if(from > 0) {
	  	tempResult = from - eachPageRecords;
	  	hrefMove = "<a href=\"javascript:move('" + tempResult + "')\">"+ "Previous		" + "</a>";
	  	out.println(hrefMove);
	  	}
	  		
	  	String hrefNumber = " ";
	  	System.out.println(" page links "+pageLinks);
	  	
		  	for(int i =0; i < pageLinks; i++) {
			if(i == 0){
			tempResult=0;
			}	
			else {
			tempResult = i * eachPageRecords ;
			}
			int j=i+1;
			if(tempResult == from) {
			out.println("<b> "+j+"</b>");
			} else {
			hrefNumber = "<a href=\"javascript:move('" + tempResult + "')\">"+ j + "</a>";	
			out.println(hrefNumber);
				}
			}
		}
			hrefMove="";
			int frmTemp = from;
			boolean flag1 = false;
	
		 	if(tempResult == frmTemp) {

			flag1=true;
			}
				
			if(flag1 == false) {
					tempResult = from + eachPageRecords;
	  				hrefMove = "<a href=\"javascript:move('" + tempResult + "')\">"+ " 	Next" + "</a>";
	  				out.println(hrefMove);
  			}
  %>	
  </td>		
  </tr>
  
	
	</div>
<%
		}else {
%>
				
				<tr>
					<td  align="center" colspan="7"><br><b>No student is yet admitted in selected class.</b><br></td>
				</tr>
				
<%
		}//end of if(omlist.size()>0)
		
		} //end of if(classStructureId !=null)

%>
</table>	
		
<%	
	}catch(Exception e){
	     Logger.log(""+e);
	      
	} 
%>

	</form>
<%
if(printFlag.trim().equalsIgnoreCase("false")){
%>	
  <%-- <jsp:include page="/footer.jsp" />
   --%>
  
<%
	}
%>
  </body>
</html>
